import com.sun.corba.se.impl.orbutil.ObjectWriter;
import org.junit.jupiter.api.Test;

import java.io.*;
import java.util.Random;
import java.util.Scanner;

public class MyTestIO {
    public static void main(String[] args) {
        String aa="zhangsan\nlisi\nwangwu\nzhaoliu\n";
        String [] strings=aa.split("\n");
        Random random=new Random();
        int i = random.nextInt(strings.length);
        System.out.println(strings[i]);
    }
    @Test
    public void login(){
        String aa="username=zhangsan&password=123";
        String[] strings=aa.split("&");//["username=zhangsan",password=123]
        String a1=strings[0];
//        String a1="username=zhangsan";
        String[] us=a1.split("=");//["username","zhangsan"]
//        String name=us[1];
      String name=  (strings[0].split("="))[1];
      String pass=  strings[1].split("=")[1];
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入用户名");
        String username=scanner.next();
        System.out.println("请输入密码");
        String password=scanner.next();
        if(username.equals(name)&&password.equals(pass)){
            System.out.println("登录成功");
        }
    }
    @Test
    public void aa() throws IOException, ClassNotFoundException {
        String path="E:\\wanxi\\canyin02-20230213\\day20反射枚举\\src\\aa.txt";
        OutputStream outputStream=new FileOutputStream(path);
        ObjectOutputStream objectWriter=new ObjectOutputStream(outputStream);
        Student student=new Student("zhangsan","123");
        objectWriter.writeObject(student);

        ObjectInputStream objectInputStream=new ObjectInputStream(new FileInputStream(path));
        Student o = (Student) objectInputStream.readObject();
        System.out.println(o);
    }
}
